<?php

namespace App\Models\MainDB;

use Illuminate\Database\Eloquent\Model;

class ShumeiCallback extends Model{

    protected $table = 'ln_shumei_callback';

    protected $primaryKey = 'id';

    protected $fillable = [
        'id',      //主键ID
        'request_id',         //
        'room_id',      //
        'user_id',      //
        'pit_number',      //
        'score',      //
        'audio_endtime',      //
        'audio_starttime',      //
        'audio_text',      //
        'audio_url',      //
        'add_time',      //
        'risk_type',      //
        'risk_desc',      //
    ];

    public $timestamps = false;

    public function getRecordList($where, $perPage = 20)
    {
        $dataList = $this->from('ln_shumei_callback as sc')
            ->select('sc.id', 'sc.pit_number', 'sc.score', 'sc.risk_type', 'sc.risk_desc', 'sc.audio_starttime', 'sc.audio_endtime', 'sc.audio_text', 'sc.audio_url', 'sc.add_time', 'ur.room_id', 'ur.room_name', 'ud.user_code', 'ud.nickname', 'ur.room_name')
            ->leftJoin('ln_user_data as ud', 'sc.user_id', '=', 'ud.user_id')
            ->leftJoin('ln_user_room as ur', 'sc.room_id', '=', 'ur.id')
            ->where($where)
            ->orderBy('sc.id', 'desc')
            ->paginate($perPage);
        return $dataList;
    }

}